package com.firmboy.log.base.bean;

/**
 * 前后台交互用到的基本格式类
 *
 * @author firmboy
 * @create 2018-03-17 下午3:07
 **/
public class BaseMsg {

    private String msgValue;  //执行结果的描述

    private String msgCode; //执行结果的代码

    private ResultFlag msgType; //后台返回给前台的信息类型（1代表success，0代表有错误）

    private Object data;  //后台返回给前台的数据

    private String msg;     //后台传递给前台的信息，由使用者自定义

    public String getMsgValue() {
        return msgValue;
    }

    public void setMsgValue(String msgValue) {
        this.msgValue = msgValue;
    }

    public String getMsgCode() {
        return msgCode;
    }

    public void setMsgCode(String msgCode) {
        this.msgCode = msgCode;
    }

    public ResultFlag getMsgType() {
        return msgType;
    }

    public void setMsgType(ResultFlag msgType) {
        this.msgType = msgType;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public static BaseMsg successMsg(){
        BaseMsg msg = new BaseMsg();
        msg.setMsgType(ResultFlag.SUCCESS);
        msg.setMsgValue(Result.SUCCESS.getValue());
        msg.setMsgCode(Result.SUCCESS.getCode());
        msg.setMsg("执行成功");
        return msg;
    }

    public static BaseMsg successMsg(Object data){
        BaseMsg msg = new BaseMsg();
        msg.setMsgType(ResultFlag.SUCCESS);
        msg.setMsgValue(Result.SUCCESS.getValue());
        msg.setMsgCode(Result.SUCCESS.getCode());
        msg.setMsg("执行成功");
        msg.setData(data);
        return msg;
    }

    public static BaseMsg failMsg(){
        BaseMsg msg = new BaseMsg();
        msg.setMsgType(ResultFlag.FAIL);
        msg.setMsgValue(Result.FAIL.getValue());
        msg.setMsgCode(Result.FAIL.getCode());
        msg.setMsg("执行失败");
        return msg;
    }
}
